package com.youhome.analysis.processor;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.youhome.analysis.model.CustomerType;
import com.youhome.service.listhub.ListingItemType;
import org.springframework.batch.item.validator.ValidatingItemProcessor;
import org.springframework.batch.item.validator.ValidationException;

/**
 * create by jack 2017/10/28
 * 处理
 */
public class HouseItemProcessor extends ValidatingItemProcessor<ListingItemType> {
    @Override
    public ListingItemType process(ListingItemType item) throws ValidationException {
        /**
         * 需要执行super.process(item)才会调用自定义校验器
         */
        super.process(item);
        /**
         * 对数据进行简单的处理，若民族为汉族，则数据转换为01，其余转换为02
         */
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            System.err.println("item:" + objectMapper.writeValueAsString(item));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return item;
    }
}
